﻿namespace IPTableAdapters
{
    using System;
    using System.CodeDom.Compiler;
    using System.ComponentModel;
    using System.ComponentModel.Design;
    using System.Configuration;
    using System.Data;
    using System.Data.Common;
    using System.Data.SqlClient;
    using System.Diagnostics;

    [ToolboxItem(true), HelpKeyword("vs.data.TableAdapter"), GeneratedCode("System.Data.Design.TypedDataSetGenerator", "2.0.0.0"), DesignerCategory("code"), Designer("Microsoft.VSDesigner.DataSource.Design.TableAdapterDesigner, Microsoft.VSDesigner, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"), DataObject(true)]
    public class ClientTableAdapter : Component
    {
        private SqlDataAdapter _adapter;
        private bool _clearBeforeFill;
        private SqlCommand[] _commandCollection;
        private SqlConnection _connection;

        /*[DebuggerNonUserCode]*/
        public ClientTableAdapter()
        {
            this.ClearBeforeFill = true;
        }

        [DebuggerNonUserCode, HelpKeyword("vs.data.TableAdapter"), DataObjectMethod(DataObjectMethodType.Delete, true)]
        public virtual int Delete(bool IsDelete, string DeleteBy, string DeleteIP, string Original_Client)
        {
            int ret;

            this.Adapter.DeleteCommand.Parameters[0].Value = IsDelete;

            if (DeleteBy == null)
            {
                throw new ArgumentNullException("DeleteBy");
            }
            this.Adapter.DeleteCommand.Parameters[1].Value = DeleteBy;

            if (DeleteIP == null)
            {
                this.Adapter.DeleteCommand.Parameters[2].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.DeleteCommand.Parameters[2].Value = DeleteIP;
            }

            if (Original_Client == null)
            {
                throw new ArgumentNullException("Original_Client");
            }
            this.Adapter.DeleteCommand.Parameters[3].Value = Original_Client;
            ConnectionState previousConnectionState = this.Adapter.DeleteCommand.Connection.State;
            if ((this.Adapter.DeleteCommand.Connection.State & ConnectionState.Open) != ConnectionState.Open)
            {
                this.Adapter.DeleteCommand.Connection.Open();
            }
            try
            {
                ret = this.Adapter.DeleteCommand.ExecuteNonQuery();
            }
            finally
            {
                if (previousConnectionState == ConnectionState.Closed)
                {
                    this.Adapter.DeleteCommand.Connection.Close();
                }
            }
            return ret;
        }

        [DataObjectMethod(DataObjectMethodType.Select, true), HelpKeyword("vs.data.TableAdapter"), DebuggerNonUserCode]
        public virtual IP.ClientDataTable GetClientData(bool SuperUser, string OwnerGroupID)
        {
            this.Adapter.SelectCommand = this.CommandCollection[0];
            this.Adapter.SelectCommand.Parameters[0].Value = SuperUser;
            if (OwnerGroupID == null)
            {
                throw new ArgumentNullException("OwnerGroupID");
            }
            this.Adapter.SelectCommand.Parameters[1].Value = OwnerGroupID;
            IP.ClientDataTable dataTable = new IP.ClientDataTable();
            this.Adapter.Fill(dataTable);
            return dataTable;
        }

        /*[DebuggerNonUserCode]*/
        private void InitAdapter()
        {
            this._adapter = new SqlDataAdapter();
            DataTableMapping tableMapping = new DataTableMapping();
            tableMapping.SourceTable = "Table";
            tableMapping.DataSetTable = "Client";
            tableMapping.ColumnMappings.Add("Client", "Client");
            tableMapping.ColumnMappings.Add("Name", "Name");
            tableMapping.ColumnMappings.Add("ChineseName", "ChineseName");
            tableMapping.ColumnMappings.Add("Address", "Address");
            tableMapping.ColumnMappings.Add("ContactPerson", "ContactPerson");
            tableMapping.ColumnMappings.Add("JobTitle", "JobTitle");
            tableMapping.ColumnMappings.Add("Phone", "Phone");
            tableMapping.ColumnMappings.Add("Fax", "Fax");
            tableMapping.ColumnMappings.Add("Phone2", "Phone2");
            tableMapping.ColumnMappings.Add("MobilePhone", "MobilePhone");
            tableMapping.ColumnMappings.Add("MobilePhone2", "MobilePhone2");
            tableMapping.ColumnMappings.Add("WebSite", "WebSite");
            tableMapping.ColumnMappings.Add("EmailAddress", "EmailAddress");
            tableMapping.ColumnMappings.Add("EmailAddress2", "EmailAddress2");
            tableMapping.ColumnMappings.Add("CreateBy", "CreateBy");
            tableMapping.ColumnMappings.Add("CreateDate", "CreateDate");
            tableMapping.ColumnMappings.Add("UpdateBy", "UpdateBy");
            tableMapping.ColumnMappings.Add("UpdateDate", "UpdateDate");
            tableMapping.ColumnMappings.Add("OwnerGroupID", "OwnerGroupID");
            tableMapping.ColumnMappings.Add("ContactPerson2", "ContactPerson2");
            tableMapping.ColumnMappings.Add("Fax2", "Fax2");
            tableMapping.ColumnMappings.Add("CreateIP", "CreateIP");
            tableMapping.ColumnMappings.Add("UpdateIP", "UpdateIP");
            tableMapping.ColumnMappings.Add("IsDelete", "IsDelete");
            tableMapping.ColumnMappings.Add("DeleteBy", "DeleteBy");
            tableMapping.ColumnMappings.Add("DeleteIP", "DeleteIP");
            
            this._adapter.TableMappings.Add(tableMapping);
            this._adapter.DeleteCommand = new SqlCommand();
            this._adapter.DeleteCommand.Connection = this.Connection;
            //this._adapter.DeleteCommand.CommandText = "DELETE FROM [Client] WHERE (([Client] = @Original_Client))";
            this._adapter.DeleteCommand.CommandText = "UPDATE [Client] SET IsDelete = @IsDelete,DeleteBy = @DeleteBy,DeleteDate = GETDATE(), DeleteIP = @DeleteIP WHERE (([Client] = @Original_Client))";
            this._adapter.DeleteCommand.CommandType = CommandType.Text;
            this._adapter.DeleteCommand.Parameters.Add(new SqlParameter("@IsDelete", SqlDbType.Bit, 1, ParameterDirection.Input, 0, 0, "IsDelete", DataRowVersion.Original, false, null, "", "", ""));
            this._adapter.DeleteCommand.Parameters.Add(new SqlParameter("@DeleteBy", SqlDbType.NVarChar, 60, ParameterDirection.Input, 0, 0, "DeleteBy", DataRowVersion.Original, false, null, "", "", ""));
            this._adapter.DeleteCommand.Parameters.Add(new SqlParameter("@DeleteIP", SqlDbType.NVarChar, 50, ParameterDirection.Input, 0, 0, "DeleteIP", DataRowVersion.Original, false, null, "", "", ""));
            this._adapter.DeleteCommand.Parameters.Add(new SqlParameter("@Original_Client", SqlDbType.NVarChar, 0, ParameterDirection.Input, 0, 0, "Client", DataRowVersion.Original, false, null, "", "", ""));
            this._adapter.InsertCommand = new SqlCommand();
            this._adapter.InsertCommand.Connection = this.Connection;
            this._adapter.InsertCommand.CommandText = "INSERT INTO Client\r\n                      (Client, Name, ChineseName, Address, ContactPerson, JobTitle, Phone, Fax, Phone2, MobilePhone, MobilePhone2, WebSite, EmailAddress, \r\n                      EmailAddress2, CreateBy, UpdateBy, OwnerGroupID, ContactPerson2, Fax2, CreateIP)\r\nVALUES     (@Client,@Name,@ChineseName,@Address,@ContactPerson,@JobTitle,@Phone,@Fax,@Phone2,@MobilePhone,@MobilePhone2,@WebSite,@EmailAddress,@EmailAddress2,@CreateBy,@UpdateBy,@OwnerGroupID,@ContactPerson2,@Fax2, @CreateIP)";
            this._adapter.InsertCommand.CommandType = CommandType.Text;
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@Client", SqlDbType.NVarChar, 60, ParameterDirection.Input, 0, 0, "Client", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@Name", SqlDbType.NVarChar, 200, ParameterDirection.Input, 0, 0, "Name", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@ChineseName", SqlDbType.NVarChar, 200, ParameterDirection.Input, 0, 0, "ChineseName", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@Address", SqlDbType.NVarChar, 200, ParameterDirection.Input, 0, 0, "Address", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@ContactPerson", SqlDbType.NVarChar, 60, ParameterDirection.Input, 0, 0, "ContactPerson", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@JobTitle", SqlDbType.NVarChar, 120, ParameterDirection.Input, 0, 0, "JobTitle", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@Phone", SqlDbType.NVarChar, 60, ParameterDirection.Input, 0, 0, "Phone", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@Fax", SqlDbType.NVarChar, 60, ParameterDirection.Input, 0, 0, "Fax", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@Phone2", SqlDbType.NVarChar, 60, ParameterDirection.Input, 0, 0, "Phone2", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@MobilePhone", SqlDbType.NVarChar, 60, ParameterDirection.Input, 0, 0, "MobilePhone", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@MobilePhone2", SqlDbType.NVarChar, 60, ParameterDirection.Input, 0, 0, "MobilePhone2", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@WebSite", SqlDbType.NVarChar, 200, ParameterDirection.Input, 0, 0, "WebSite", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@EmailAddress", SqlDbType.NVarChar, 60, ParameterDirection.Input, 0, 0, "EmailAddress", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@EmailAddress2", SqlDbType.NVarChar, 60, ParameterDirection.Input, 0, 0, "EmailAddress2", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@CreateBy", SqlDbType.NVarChar, 60, ParameterDirection.Input, 0, 0, "CreateBy", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@UpdateBy", SqlDbType.NVarChar, 60, ParameterDirection.Input, 0, 0, "UpdateBy", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@OwnerGroupID", SqlDbType.NVarChar, 60, ParameterDirection.Input, 0, 0, "OwnerGroupID", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@ContactPerson2", SqlDbType.NVarChar, 60, ParameterDirection.Input, 0, 0, "ContactPerson2", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@Fax2", SqlDbType.NVarChar, 60, ParameterDirection.Input, 0, 0, "Fax2", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@CreateIP", SqlDbType.NVarChar, 50, ParameterDirection.Input, 0, 0, "CreateIP", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand = new SqlCommand();
            this._adapter.UpdateCommand.Connection = this.Connection;
            this._adapter.UpdateCommand.CommandText = "UPDATE    Client\r\nSET              Name = @Name, ChineseName = @ChineseName, Address = @Address, ContactPerson = @ContactPerson, JobTitle = @JobTitle, Phone = @Phone, \r\n                      Fax = @Fax, Phone2 = @Phone2, MobilePhone = @MobilePhone, MobilePhone2 = @MobilePhone2, WebSite = @WebSite, \r\n                      EmailAddress = @EmailAddress, EmailAddress2 = @EmailAddress2, UpdateBy = @UpdateBy, UpdateDate = GETDATE(), \r\n                      ContactPerson2 = @ContactPerson2, Fax2 = @Fax2, UpdateIP = @UpdateIP \r\nWHERE     (Client = @Original_Client)";
            this._adapter.UpdateCommand.CommandType = CommandType.Text;
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@Name", SqlDbType.NVarChar, 200, ParameterDirection.Input, 0, 0, "Name", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@ChineseName", SqlDbType.NVarChar, 200, ParameterDirection.Input, 0, 0, "ChineseName", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@Address", SqlDbType.NVarChar, 200, ParameterDirection.Input, 0, 0, "Address", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@ContactPerson", SqlDbType.NVarChar, 60, ParameterDirection.Input, 0, 0, "ContactPerson", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@JobTitle", SqlDbType.NVarChar, 120, ParameterDirection.Input, 0, 0, "JobTitle", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@Phone", SqlDbType.NVarChar, 60, ParameterDirection.Input, 0, 0, "Phone", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@Fax", SqlDbType.NVarChar, 60, ParameterDirection.Input, 0, 0, "Fax", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@Phone2", SqlDbType.NVarChar, 60, ParameterDirection.Input, 0, 0, "Phone2", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@MobilePhone", SqlDbType.NVarChar, 60, ParameterDirection.Input, 0, 0, "MobilePhone", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@MobilePhone2", SqlDbType.NVarChar, 60, ParameterDirection.Input, 0, 0, "MobilePhone2", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@WebSite", SqlDbType.NVarChar, 200, ParameterDirection.Input, 0, 0, "WebSite", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@EmailAddress", SqlDbType.NVarChar, 60, ParameterDirection.Input, 0, 0, "EmailAddress", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@EmailAddress2", SqlDbType.NVarChar, 60, ParameterDirection.Input, 0, 0, "EmailAddress2", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@UpdateBy", SqlDbType.NVarChar, 60, ParameterDirection.Input, 0, 0, "UpdateBy", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@ContactPerson2", SqlDbType.NVarChar, 60, ParameterDirection.Input, 0, 0, "ContactPerson2", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@Fax2", SqlDbType.NVarChar, 60, ParameterDirection.Input, 0, 0, "Fax2", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@UpdateIP", SqlDbType.NVarChar, 50, ParameterDirection.Input, 0, 0, "UpdateIP", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@Original_Client", SqlDbType.NVarChar, 60, ParameterDirection.Input, 0, 0, "Client", DataRowVersion.Original, false, null, "", "", ""));
        }

        /*[DebuggerNonUserCode]*/
        private void InitCommandCollection()
        {
            this._commandCollection = new SqlCommand[] { new SqlCommand() };
            this._commandCollection[0].Connection = this.Connection;
            this._commandCollection[0].CommandText = "SELECT     Client, Name, ChineseName, Address, ContactPerson, JobTitle, Phone, Fax, Phone2, MobilePhone, MobilePhone2, WebSite, EmailAddress, \r\n                      EmailAddress2, CreateBy, CreateDate, UpdateBy, UpdateDate, OwnerGroupID, ContactPerson2, Fax2, IsDelete \r\nFROM         Client\r\nWHERE     (@SuperUser = 1) OR\r\n                      (OwnerGroupID = @OwnerGroupID AND IsDelete = 0 )";
            this._commandCollection[0].CommandType = CommandType.Text;
            this._commandCollection[0].Parameters.Add(new SqlParameter("@SuperUser", SqlDbType.Bit, 0x400, ParameterDirection.Input, 0, 0, "", DataRowVersion.Current, false, null, "", "", ""));
            this._commandCollection[0].Parameters.Add(new SqlParameter("@OwnerGroupID", SqlDbType.NVarChar, 60, ParameterDirection.Input, 0, 0, "OwnerGroupID", DataRowVersion.Current, false, null, "", "", ""));
        }

        /*[DebuggerNonUserCode]*/
        private void InitConnection()
        {
            this._connection = new SqlConnection();
            this._connection.ConnectionString = ConfigurationManager.ConnectionStrings["LocalSqlConnection1"].ConnectionString;
        }

        [DataObjectMethod(DataObjectMethodType.Insert, true), DebuggerNonUserCode, HelpKeyword("vs.data.TableAdapter")]
        public virtual int Insert(string Client, string Name, string ChineseName, string Address, string ContactPerson, string JobTitle, string Phone, string Fax, string Phone2, string MobilePhone, string MobilePhone2, string WebSite, string EmailAddress, string EmailAddress2, string CreateBy, string UpdateBy, string OwnerGroupID, string ContactPerson2, string Fax2, string CreateIP)
        {
            int ret;
            if (Client == null)
            {
                throw new ArgumentNullException("Client");
            }
            this.Adapter.InsertCommand.Parameters[0].Value = Client;
            if (Name == null)
            {
                this.Adapter.InsertCommand.Parameters[1].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.InsertCommand.Parameters[1].Value = Name;
            }
            if (ChineseName == null)
            {
                this.Adapter.InsertCommand.Parameters[2].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.InsertCommand.Parameters[2].Value = ChineseName;
            }
            if (Address == null)
            {
                this.Adapter.InsertCommand.Parameters[3].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.InsertCommand.Parameters[3].Value = Address;
            }
            if (ContactPerson == null)
            {
                this.Adapter.InsertCommand.Parameters[4].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.InsertCommand.Parameters[4].Value = ContactPerson;
            }
            if (JobTitle == null)
            {
                this.Adapter.InsertCommand.Parameters[5].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.InsertCommand.Parameters[5].Value = JobTitle;
            }
            if (Phone == null)
            {
                this.Adapter.InsertCommand.Parameters[6].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.InsertCommand.Parameters[6].Value = Phone;
            }
            if (Fax == null)
            {
                this.Adapter.InsertCommand.Parameters[7].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.InsertCommand.Parameters[7].Value = Fax;
            }
            if (Phone2 == null)
            {
                this.Adapter.InsertCommand.Parameters[8].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.InsertCommand.Parameters[8].Value = Phone2;
            }
            if (MobilePhone == null)
            {
                this.Adapter.InsertCommand.Parameters[9].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.InsertCommand.Parameters[9].Value = MobilePhone;
            }
            if (MobilePhone2 == null)
            {
                this.Adapter.InsertCommand.Parameters[10].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.InsertCommand.Parameters[10].Value = MobilePhone2;
            }
            if (WebSite == null)
            {
                this.Adapter.InsertCommand.Parameters[11].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.InsertCommand.Parameters[11].Value = WebSite;
            }
            if (EmailAddress == null)
            {
                this.Adapter.InsertCommand.Parameters[12].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.InsertCommand.Parameters[12].Value = EmailAddress;
            }
            if (EmailAddress2 == null)
            {
                this.Adapter.InsertCommand.Parameters[13].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.InsertCommand.Parameters[13].Value = EmailAddress2;
            }
            if (CreateBy == null)
            {
                throw new ArgumentNullException("CreateBy");
            }
            this.Adapter.InsertCommand.Parameters[14].Value = CreateBy;
            if (UpdateBy == null)
            {
                throw new ArgumentNullException("UpdateBy");
            }
            this.Adapter.InsertCommand.Parameters[15].Value = UpdateBy;
            if (OwnerGroupID == null)
            {
                throw new ArgumentNullException("OwnerGroupID");
            }
            this.Adapter.InsertCommand.Parameters[0x10].Value = OwnerGroupID;
            if (ContactPerson2 == null)
            {
                this.Adapter.InsertCommand.Parameters[0x11].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.InsertCommand.Parameters[0x11].Value = ContactPerson2;
            }
            if (Fax2 == null)
            {
                this.Adapter.InsertCommand.Parameters[0x12].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.InsertCommand.Parameters[0x12].Value = Fax2;
            }

            if (CreateIP == null)
            {
                this.Adapter.InsertCommand.Parameters[19].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.InsertCommand.Parameters[19].Value = CreateIP;
            }

            ConnectionState previousConnectionState = this.Adapter.InsertCommand.Connection.State;
            if ((this.Adapter.InsertCommand.Connection.State & ConnectionState.Open) != ConnectionState.Open)
            {
                this.Adapter.InsertCommand.Connection.Open();
            }
            try
            {
                ret = this.Adapter.InsertCommand.ExecuteNonQuery();
            }
            finally
            {
                if (previousConnectionState == ConnectionState.Closed)
                {
                    this.Adapter.InsertCommand.Connection.Close();
                }
            }
            return ret;
        }

        [HelpKeyword("vs.data.TableAdapter"), DebuggerNonUserCode]
        public virtual int Update(IP dataSet)
        {
            return this.Adapter.Update(dataSet, "Client");
        }

        [HelpKeyword("vs.data.TableAdapter"), DebuggerNonUserCode]
        public virtual int Update(DataRow[] dataRows)
        {
            return this.Adapter.Update(dataRows);
        }

        [HelpKeyword("vs.data.TableAdapter"), DebuggerNonUserCode]
        public virtual int Update(IP.ClientDataTable dataTable)
        {
            return this.Adapter.Update(dataTable);
        }

        [DebuggerNonUserCode, HelpKeyword("vs.data.TableAdapter")]
        public virtual int Update(DataRow dataRow)
        {
            return this.Adapter.Update(new DataRow[] { dataRow });
        }

        [DataObjectMethod(DataObjectMethodType.Update, true), DebuggerNonUserCode, HelpKeyword("vs.data.TableAdapter")]
        public virtual int Update(string Name, string ChineseName, string Address, string ContactPerson, string JobTitle, string Phone, string Fax, string Phone2, string MobilePhone, string MobilePhone2, string WebSite, string EmailAddress, string EmailAddress2, string UpdateBy, string ContactPerson2, string Fax2, string UpdateIP, string Original_Client)
        {
            int ret;
            if (Name == null)
            {
                this.Adapter.UpdateCommand.Parameters[0].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.UpdateCommand.Parameters[0].Value = Name;
            }
            if (ChineseName == null)
            {
                this.Adapter.UpdateCommand.Parameters[1].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.UpdateCommand.Parameters[1].Value = ChineseName;
            }
            if (Address == null)
            {
                this.Adapter.UpdateCommand.Parameters[2].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.UpdateCommand.Parameters[2].Value = Address;
            }
            if (ContactPerson == null)
            {
                this.Adapter.UpdateCommand.Parameters[3].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.UpdateCommand.Parameters[3].Value = ContactPerson;
            }
            if (JobTitle == null)
            {
                this.Adapter.UpdateCommand.Parameters[4].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.UpdateCommand.Parameters[4].Value = JobTitle;
            }
            if (Phone == null)
            {
                this.Adapter.UpdateCommand.Parameters[5].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.UpdateCommand.Parameters[5].Value = Phone;
            }
            if (Fax == null)
            {
                this.Adapter.UpdateCommand.Parameters[6].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.UpdateCommand.Parameters[6].Value = Fax;
            }
            if (Phone2 == null)
            {
                this.Adapter.UpdateCommand.Parameters[7].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.UpdateCommand.Parameters[7].Value = Phone2;
            }
            if (MobilePhone == null)
            {
                this.Adapter.UpdateCommand.Parameters[8].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.UpdateCommand.Parameters[8].Value = MobilePhone;
            }
            if (MobilePhone2 == null)
            {
                this.Adapter.UpdateCommand.Parameters[9].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.UpdateCommand.Parameters[9].Value = MobilePhone2;
            }
            if (WebSite == null)
            {
                this.Adapter.UpdateCommand.Parameters[10].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.UpdateCommand.Parameters[10].Value = WebSite;
            }
            if (EmailAddress == null)
            {
                this.Adapter.UpdateCommand.Parameters[11].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.UpdateCommand.Parameters[11].Value = EmailAddress;
            }
            if (EmailAddress2 == null)
            {
                this.Adapter.UpdateCommand.Parameters[12].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.UpdateCommand.Parameters[12].Value = EmailAddress2;
            }
            if (UpdateBy == null)
            {
                throw new ArgumentNullException("UpdateBy");
            }
            this.Adapter.UpdateCommand.Parameters[13].Value = UpdateBy;
            if (ContactPerson2 == null)
            {
                this.Adapter.UpdateCommand.Parameters[14].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.UpdateCommand.Parameters[14].Value = ContactPerson2;
            }
            if (Fax2 == null)
            {
                this.Adapter.UpdateCommand.Parameters[15].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.UpdateCommand.Parameters[15].Value = Fax2;
            }

            if (UpdateIP == null)
            {
                this.Adapter.UpdateCommand.Parameters[16].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.UpdateCommand.Parameters[16].Value = UpdateIP;
            }

            if (Original_Client == null)
            {
                throw new ArgumentNullException("Original_Client");
            }
            this.Adapter.UpdateCommand.Parameters[17].Value = Original_Client;
            ConnectionState previousConnectionState = this.Adapter.UpdateCommand.Connection.State;
            if ((this.Adapter.UpdateCommand.Connection.State & ConnectionState.Open) != ConnectionState.Open)
            {
                this.Adapter.UpdateCommand.Connection.Open();
            }
            try
            {
                ret = this.Adapter.UpdateCommand.ExecuteNonQuery();
            }
            finally
            {
                if (previousConnectionState == ConnectionState.Closed)
                {
                    this.Adapter.UpdateCommand.Connection.Close();
                }
            }
            return ret;
        }

        /*[DebuggerNonUserCode]*/
        private SqlDataAdapter Adapter
        {
            get
            {
                if (this._adapter == null)
                {
                    this.InitAdapter();
                }
                return this._adapter;
            }
        }

        /*[DebuggerNonUserCode]*/
        public bool ClearBeforeFill
        {
            get
            {
                return this._clearBeforeFill;
            }
            set
            {
                this._clearBeforeFill = value;
            }
        }

        /*[DebuggerNonUserCode]*/
        protected SqlCommand[] CommandCollection
        {
            get
            {
                if (this._commandCollection == null)
                {
                    this.InitCommandCollection();
                }
                return this._commandCollection;
            }
        }

        /*[DebuggerNonUserCode]*/
        internal SqlConnection Connection
        {
            get
            {
                if (this._connection == null)
                {
                    this.InitConnection();
                }
                return this._connection;
            }
            set
            {
                this._connection = value;
                if (this.Adapter.InsertCommand != null)
                {
                    this.Adapter.InsertCommand.Connection = value;
                }
                if (this.Adapter.DeleteCommand != null)
                {
                    this.Adapter.DeleteCommand.Connection = value;
                }
                if (this.Adapter.UpdateCommand != null)
                {
                    this.Adapter.UpdateCommand.Connection = value;
                }
                for (int i = 0; i < this.CommandCollection.Length; i++)
                {
                    if (this.CommandCollection[i] != null)
                    {
                        this.CommandCollection[i].Connection = value;
                    }
                }
            }
        }
    }
}

